#include "component/admin/TopicController.h"

namespace zeroplus::mq
{
    TopicController::TopicController(const std::string &uri)
    {
        Uri uriParser = Uri(uri);
        routeInfoDownloader_ = std::make_shared<admin::RouteInfoDownloader>(uriParser.GetUri());
        topicManager_ = std::make_shared<admin::TopicManager>();
    }

    TopicController::~TopicController()
    {
    }

    void TopicController::Start()
    {
        auto clusterInfo = routeInfoDownloader_->QueryBrokerClusterInfo();
        topicManager_->ConnectToAllBrokerServer(clusterInfo);
    }

    bool TopicController::AddTopic(const std::vector<std::vector<std::string>> &topic2D)
    {
        topicManager_->AddTopic(topic2D);
    }

    bool TopicController::DelTopic(const std::string &topic)
    {
        topicManager_->DelTopic(topic);
    }

}